﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.DataAnnotations;
using LunwenYun.Infrastructure.Entities.Repository;
using LunwenYun.Infrastructure.Entities.Enum;

namespace LunwenYun.Infrastructure.Entities.Entity
{
    public class TradeHistory : IAccessible<T_TradeHistory, TradeHistory>, ILogicEntity<T_TradeHistory, TradeHistory>
    {
        #region
        public int Id { get; set; }
        public int TradeId { get; set; }
        public TradeStatus PreStatus { get; set; }
        public TradeStatus NxtStatus { get; set; }
        public string Remark { get; set; }
        public DateTime RecordDate { get; set; }
        public string Operator { get; set; }
        #endregion


        protected override void Covariant(T_TradeHistory model)
        {
            if (model != null)
            {
                this.Id = model.Id;
                this.NxtStatus = (TradeStatus)model.NxtStatus;
                this.Operator = model.Operator;
                this.PreStatus = (TradeStatus)model.PreStatus;
                this.RecordDate = model.RecordDate;
                this.Remark = model.Remark;
                this.TradeId = model.TradeId;
            }
        }

        protected override T_TradeHistory Inverter(TradeHistory model)
        {
            if (model != null)
            {
                return new T_TradeHistory()
                {
                    Id = model.Id,
                    NxtStatus = (int)model.NxtStatus,
                    Operator = model.Operator,
                    PreStatus = (int)model.PreStatus,
                    RecordDate = model.RecordDate,
                    Remark = model.Remark,
                    TradeId = model.TradeId
                };
            }
            return null;
        }

        public TradeHistory Set(T_TradeHistory dbModel)
        {
            Covariant(dbModel);
            return this;
        }
    }
}
